1. Field of the Invention
The present invention relates to a record retrieval method of reading out records corresponding to designated record retrieval conditions from a data file in a data processing apparatus such as an office computer.
2. Description of the Related Art
A data file, e.g., a sales file or an inventory file, and an index file are generally stored in an external storage of a data processing apparatus.
A data file has the following format. A data file is a file arbitrarily formed by a user. Records in each file are respectively identified by index keys. As shown in FIG. 17, each record has data, such as a sales quantity and a sales amount, in fields corresponding to the number of necessary items, which follow a corresponding index key. Note that the respective records in a data file are not arranged in the order of index keys but are arranged in the order of, e.g., records formed by a user. In contrast to this, in an index file, data consisting of index keys and physical addresses, of a data file, at which records corresponding to the keys are stored, are arranged in the order of the keys (increasing order or decreasing order), as shown in FIG. 17.
When desired records are to be retrieved from a data file having the above-described format by using, for example, the following conditions, high-speed record retrieval cannot be expected.
Assume that record retrieval is performed on the basis of the following OR conditions, i.e., conditions 1 to 5 designated by key words:
Condition 1: 0003.ltoreq.keyword&lt;0200; field 3=0009 PA1 Condition 2: 0100&lt;keyword.ltoreq.0400; field 4=0007 PA1 Condition 3: keyword=0402 PA1 Condition 4: 0600.ltoreq.keyword.ltoreq.0900; field 3=0006 PA1 Condition 5: 0700.ltoreq.keyword&lt;1000; field 4=0011
If field conditions are set in addition to keywords, record retrieval is performed as follows. The index file is accessed first to read out records having index keys corresponding to the keywords from the data file. Subsequently, records corresponding to the field conditions are selected from the records.
A conventional record retrieval method will be described in detail below with reference to FIG. 18. FIG. 18 shows an example of data indicating a correspondence between index keys sorted in the increasing order in an index file and record contents (the contents of each field), in a data file, corresponding to the index keys.
Referring to FIG. 18, reference symbols (A), (B), (C), (D), and (E) correspond to the above-mentioned record retrieval conditions "condition 1", "condition 2", "condition 3", "condition 4", and "condition 5" and denote records read out from the data file when they satisfy the respective key conditions. Note that "condition 3" includes only one key condition, but other conditions include field conditions as well as key conditions. That is, reference symbols (A), (B), (D), and (E) respectively denote record groups which satisfy the key conditions of "condition 1", "condition 2", "condition 4", and "condition 5" and are read out from the data file to check whether they satisfy other conditions (field conditions) as well.
Records, of the record group (A) read out from the data file in this manner, which satisfy the field condition of "condition 1" are records having index keys "0003" and "0103". Records which satisfy the field condition of "condition 2" are records having index keys "0103" and "0302". Records which satisfy the field condition of "condition 4" are records having index keys "0702" and "0802". In addition, records having index keys "0702" and "0901" satisfy the field condition of "condition 5".
when record retrieval is performed on the basis of "condition 1" to "condition 5" described above, however, since the ranges defined by the key conditions of "condition 1" and "condition 2" and of "condition 4" and "condition 5" overlap, records in the ranges indicated by dotted lines in FIG. 18 are read out twice for the respective different conditions. Consequently, the number of records read out from the data file is increased, and the frequency of access to an external storage is increased accordingly. This greatly interferes with high-speed processing.
In addition, the same records may be retrieved twice or more depending on the designated contents of key and field conditions. For example, a record having an index key "0103" indicated by a symbol .circleincircle. is retrieved twice by "condition 1" and "condition 2". A record having an index key "0702" is retrieved twice by "condition 4" and "condition 5". In such a case, in a conventional system, identical records are searched out from a retrieved record group, and unnecessary records which are retrieved twice or more are deleted. With this operation, the processing speed is decreased.
The reason why such a decrease in processing speed occurs is that record retrieval is performed by frequent access to the data file for each condition.